//
//  BaseTableViewController.swift
//  PersonnalDiary
//
//  Created by 徐宽阔 on 15/9/27.
//  Copyright © 2015年 XDKOO. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController , VisitorViewDelegate{
    
    var isLogin = false
    
    var visitorView: VisitorView?
    
    override func loadView() {
        isLogin ? super.loadView() : setupVisitorView()
    }
    
    private func setupVisitorView()
    {
        visitorView = VisitorView()
        visitorView!.delegate = self;
        view = visitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
    }
    
    // MARK: - VisitorViewDelegate
    func visitorViewDidClickLoginBtn(visitorView: VisitorView) {
        XDKLog(__FUNCTION__)
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
    func visitorViewDidClickRegisterBtn(visitorView: VisitorView) {
        XDKLog(__FUNCTION__)
    }
}
